﻿/**
 *
 * @file   FITKHDF5AdaptorCase.h
 * @brief  HDF5 适配器 用于读写HDF5的Case。
 * @author fulipeng (flipengqd@yeah.net)
 * @date   2024-03-15
 *
 */
#ifndef __FITKHDF5ADAPTORCASE_R_H__
#define __FITKHDF5ADAPTORCASE_R_H__

#include "FITKAbaqusIOHDF5API.h"
#include "FITKAbaqusHDF5AbstractAdaptor.h"
#include "FITK_Kernel/FITKCore/FITKCoreMacros.h"
#include "FITK_Kernel/FITKAdaptor/FITKIOAdaptorFactory.h"

 //前置声明
ForwardDeclarNS(AbaqusData, FITKAbaqusPart)
ForwardDeclarNS(AbaqusData, FITKDataCase)
ForwardDeclarNS(Interface, FITKAbstractMaterial)
ForwardDeclarNS(Interface, FITKAbaAbastractSection)
ForwardDeclarNS(Interface, FITKAbaMaterial)
ForwardDeclarNS(Interface, FITKAbaAssembly)
ForwardDeclarNS(Interface, FITKAbaAbstractStep)
ForwardDeclarNS(Interface, FITKAbaAbstractAmplitude)
ForwardDeclarNS(Interface, FITKAbaProfile)
ForwardDeclarNS(Interface, FITKAbaAbstractOutput)
ForwardDeclarNS(Interface, FITKAbstractLoad)
ForwardDeclarNS(Interface, FITKAbaAbstractInteraction)
ForwardDeclarNS(Interface, FITKAbaAbstractInteractionProperty)
ForwardDeclarNS(Interface, FITKAbaAbstractConstraint)
ForwardDeclarNS(Interface, FITKAbaAbstractBoundaryCondition)
ForwardDeclarNS(Interface, FITKAbstractBC)
ForwardDeclarNS(Interface, FITKAbaTimePoints)
ForwardDeclarNS(Interface, FITKAbaConnectorSection)

namespace IO
{
    /**
     * @brief HDF5 Case 读写适配器
     * @author fulipeng (fulipengqd@yeah.net)
     * @date 2024-05-30
     */
    class FITKABAQUSIOHDF5API FITKAbaqusHDF5AdaptorCase : public FITKAbaqusHDF5AbstractAdaptor
    {
    public:
        explicit FITKAbaqusHDF5AdaptorCase() = default;
        ~FITKAbaqusHDF5AdaptorCase() = default;

        /**
         * @brief 获取适配器数据类型名
         * @return 适配器数据类型名
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-05-30
         */
        QString getAdaptorClass() override;

        /**
         * @brief 适配器读取
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-05-30
         */
        bool adaptR() override;

        /**
         * @brief 适配器写出
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-05-30
         */
        bool adaptW() override;
        /**
         * @brief 读取算例信息
         * @param h5Group 数据块
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-05-30
         */
        bool readDataCaseInfo(H5::Group& h5group);

        /**
         * @brief 写出算例信息
         * @param h5Group 数据块
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-05-30
         */
        bool writeDataCaseInfo(H5::Group& h5group);

    private:

        /**
         * @brief 读取Part结构
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-05-30
         */
        bool readPart(H5::Group& partGroup);

        /**
         * @brief 读取Assembly结构
         * @param assembly 装配
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-05-30
         */
        bool readAssembly(Interface::FITKAbaAssembly* assembly, H5::Group& h5Group);

        /**
         * @brief 读取Material结构
         * @param material 材料
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-05-30
         */
        bool readMaterial(H5::Group& h5Group);

        /**
         * @brief 读取Section结构
         * @param section 截面
         * @param h5Group
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-04
         */
        bool readSection(H5::Group& h5Group);

        /**
         * @brief 读取Profile结构
         * @param profile 剖面
         * @param h5Group
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-04
         */
        bool readProfile(H5::Group& h5Group);

        /**
         * @brief 读取分析步（Step）结构
         * @param step 分析步
         * @param h5Group
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-05-30
         */
        bool readStep(H5::Group& h5Group);

        /**
         * @brief 读取输出（Output）结构
         * @param output 输出
         * @param h5Group
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-07
         */
        bool readOutput(H5::Group& h5Group);

        /**
         * @brief 读取载荷(Load)结构
         * @param load 载荷
         * @param h5Group
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-07
         */
        bool readLoad(H5::Group& h5Group);

        /**
         * @brief 读取幅值(Amplitude)曲线
         * @param amplitude 幅值
         * @param h5Group
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-07
         */
        bool readAmplitude(H5::Group& h5Group);

        /**
         * @brief 读取相互作用(Interaction)结构
         * @param interaction 相互作用
         * @param h5Group
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-11
         */
        bool readInteraction(H5::Group& h5Group);

        /**
         * @brief 读取相互作用属性(InteractionProperty)结构
         * @param interaction 相互作用
         * @param h5Group
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-11
         */
        bool readInteractionProperty(H5::Group& h5Group);

        /**
         * @brief 读取边界条件(Boundary)结构
         * @param Boundary 边界条件
         * @param h5Group
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-11
         */
        bool readBoundary(H5::Group& h5Group);

        /**
         * @brief 读取约束(Constraint)结构
         * @param Constraint 约束
         * @param constraint
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-11
         */
        bool readConstraint(H5::Group& h5Group);

        /**
         * @brief 读取时间点(TimePoints)结构
         * @param h5Group
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-21
         */
        bool readTimePoints(H5::Group& h5Group);

        /**
         * @brief 读取连接器截面
         * @param h5Group
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-07-02
         */
        bool readConnectorSection(H5::Group& h5Group);

        /**
         * @brief 写出Part结构
         * @param part 部件
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-05-30
         */
        bool writePart(AbaqusData::FITKAbaqusPart* part, H5::Group& partGroup);

        /**
         * @brief 写出Assembly结构
         * @param assembly 装配
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-05-30
         */
        bool writeAssembly(Interface::FITKAbaAssembly* assembly, H5::Group& h5Group);

        /**
         * @brief 写出Material结构
         * @param material 材料
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-05-30
         */
        bool writeMaterial(Interface::FITKAbaMaterial* material, H5::Group& h5Group);

        /**
         * @brief 写出Section结构
         * @param section 截面
         * @param h5Group
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-04
         */
        bool writeSection(Interface::FITKAbaAbastractSection* section, H5::Group& h5Group);

        /**
         * @brief 写出Profile结构
         * @param profile 剖面
         * @param h5Group
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-04
         */
        bool writeProfile(Interface::FITKAbaProfile* profile, H5::Group& h5Group);

        /**
         * @brief 写出分析步（Step）结构
         * @param step 分析步
         * @param h5Group
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-05-30
         */
        bool writeStep(Interface::FITKAbaAbstractStep* step, H5::Group& h5Group);

        /**
         * @brief 写出输出（Output）结构
         * @param output 输出
         * @param h5Group
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-07
         */
        bool writeOutput(Interface::FITKAbaAbstractOutput* output, H5::Group& h5Group);

        /**
         * @brief 写出载荷(Load)结构
         * @param load 载荷
         * @param h5Group
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-07
         */
        bool writeLoad(Interface::FITKAbstractLoad* load, H5::Group& h5Group);

        /**
         * @brief 写出幅值(Amplitude)曲线
         * @param amplitude 幅值
         * @param h5Group
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-07
         */
        bool writeAmplitude(Interface::FITKAbaAbstractAmplitude* amplitude, H5::Group& h5Group);

        /**
         * @brief 写出相互作用(Interaction)结构
         * @param interaction 相互作用
         * @param h5Group
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-11
         */
        bool writeInteraction(Interface::FITKAbaAbstractInteraction* interaction, H5::Group& h5Group);

        /**
         * @brief 写出相互作用属性(InteractionProperty)结构
         * @param interaction 相互作用
         * @param h5Group
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-11
         */
        bool writeInteractionProperty(Interface::FITKAbaAbstractInteractionProperty* interactionProperty, H5::Group& h5Group);

        /**
         * @brief 写出边界条件(Boundary)结构
         * @param Boundary 边界条件
         * @param h5Group
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-11
         */
        bool writeBoundary(Interface::FITKAbstractBC* BoundaryCondition, H5::Group& h5Group);

        /**
         * @brief 写出约束(Constraint)结构
         * @param Constraint 约束
         * @param h5Group
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-11
         */
        bool writeConstraint(Interface::FITKAbaAbstractConstraint* constraint, H5::Group& h5Group);

        /**
         * @brief 写出时间点(TimePoints)结构
         * @param timepoints 时间点
         * @param h5Group
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-06-21
         */
        bool writeTimePoints(Interface::FITKAbaTimePoints* timepoints, H5::Group& h5Group);


        /**
         * @brief 写出连接器截面
         * @param connectorSection 连接器截面
         * @param h5Group
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-07-02
         */
        bool writeConnectorSection(Interface::FITKAbaConnectorSection* connectorSection,H5::Group& h5Group);

        /**
         * @brief 写出分析步（Step）结构
         * @param step 步骤 1 part 2 assembly 3 material 4 step
         * @param count 当前步骤的总个数
         * @param index 当前步骤的第几个
         * @return 状态 true成功， false失败
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-05-30
         */
        void sendCalculateProgress(int step, int count, int index);

    private:

        /**
         * @brief 算例数据
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-05-30
         */
        AbaqusData::FITKDataCase* _caseData{};

        /**
         * @brief 算例描述
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-05-30
         */
        QString _caseDecription;

        /**
         * @brief Preprint下的属性信息
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-05-30
         */
        bool _echo = false;
        bool _model = false;
        bool _history = false;
        bool _contact = false;
    };

    Register2FITKIOAdaptorFactory(HDF5, AbaqusData::FITKDataCase, FITKAbaqusHDF5AdaptorCase)
}


#endif // !1

